#!/bin/bash

total=$#

kill_pro() {
    pro=$(ps -elf | grep "$1.sh" | grep -v grep)
    if [[ ${pro} != '' ]]; then
        ps -elf | grep "$1.sh" | grep -v grep | awk '{print $4}' | xargs kill -9 
    fi
}

for type in $@; do
    if [[ $type == "osssync" ]]; then
        kill_pro oss_sync_check
    elif [[ $type == "all" ]]; then
        kill_pro _check
		kill_pro clean_daily
    elif [[ $type == "clean_daily" ]]; then
        kill_pro clean_daily
    else
        # type is canal, ha, mariadb, nginx, rabbitmq, tomcat
        kill_pro ${type}_check
		echo "stop ${type}_check.sh success"
    fi
done

